package com.dsh.storeManagement.controller;

import com.dsh.model.Result;
import com.dsh.storeManagement.entity.vo.AdminNameForStoreVo;
import com.dsh.storeManagement.entity.vo.AreaVo;
import com.dsh.storeManagement.entity.vo.StoreAllVo;
import com.dsh.storeManagement.entity.vo.StoreVo;
import com.dsh.storeManagement.service.StoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "门店管理")
@RestController
@RequestMapping("StoreAdministration")
public class StoreController {
    @Resource
    StoreService storeService;

    @ApiOperation("新增门店")
    @PostMapping("insertStoreAdministration")
    public Result insertStoreAdministration(@RequestBody StoreVo storeVo) {
        StoreVo insert = storeService.insert(storeVo);
        return Result.success(insert, "");
    }
    @PostMapping("updateStoreAdministration")
    @ApiOperation("修改门店信息")
    public Result updateStoreAdministration(@RequestBody StoreVo storeVo) {
        int update = storeService.update(storeVo);
        return  Result.success(update,"");
    }
    @ApiOperation(value = "根据片区的id查找门店集合",response =StoreVo.class )
    @ApiImplicitParam(paramType="query", name = "aId", value = "片区Id", required = true, dataType = "int")
    @GetMapping("selectStoreForAId")
    public Result selectStoreForAId(String name,int aId){
        List<StoreVo> storeVos = storeService.selectStoreForAId(name,aId);
        return  Result.success(storeVos,"");
    }
    @ApiOperation("市区片区和片区的id")
    @GetMapping("selectArea")
    public  Result selectArea(){
        List<AreaVo> areaVos = storeService.selectArea();
        return Result.success(areaVos,"");
    }
//    @ApiOperation("根据门店的id查找门店信息")
//    @ApiImplicitParam(paramType="query", name = "id", value = "门店Id", required = true, dataType = "int")
//    @GetMapping("selectStoreById")
//    public Result selectStoreById(int id){
//        StoreAllVo storeVo = storeService.selectStoreById(id);
//        return Result.success(storeVo,"");
//    }
    @ApiOperation("根据门店的id查找门店信息")
    @ApiImplicitParam(paramType="query", name = "id", value = "门店Id", required = true, dataType = "int")
    @GetMapping("selectForStoreId")
    public Result selectStoreById(int id){
        StoreVo storeVo = storeService.selectForStoreId(id);
        return Result.success(storeVo,"");
    }

}
